<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdminsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('admins', function (Blueprint $table) {
            $table->increments('admin_id')->comment('主键');
            $table->integer('role_id')->comment('角色ID');
            $table->string('role_name', 20)->comment('角色名称');
            $table->string('nickname', 20)->comment('笔名')->unique();
            $table->string('realname', 20)->comment('真实姓名');
            $table->string('poster', 50)->comment('个人主页海报');
            $table->string('bio')->comment('座右铭');
            $table->boolean('sex')->comment('性别0->男 1->女')->nullable();
            $table->string('password', 60)->comment('密码');
            $table->string('email', 20)->comment('邮箱')->unique();
            $table->string('phone', 11)->comment('手机号')->unique();
            $table->string('avatar', 50)->comment('头像');
            $table->integer('attempts')->default(0)->comment('尝试登录次数');
            $table->boolean('status')->comment('管理员状态0->锁定 1->正常')->default(1);
            $table->rememberToken();
            $table->timestamp('last_login_at')->comment('上次登录时间')->nullable();
            $table->timestamp('last_action_at')->comment('上次操作时间')->nullable();
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admins');
    }
}
